|
|
|
|
|
|
|
Figure 4.9
Example program CurveTxt draws text along curves and circles. |
|
|
|
|
|
|
|
|
Printers usually have a much higher resolution than a typical computer screen, so rotated fonts look much smoother when drawn directly on a printer. |
|
|
|
|
|
|
|
|
Centering normal text is relatively easy. You can use the TextWidth and TextHeight functions to see how much room the string will occupy. Then you can subtract half of these values from coordinates of the string's desired center position. The following code shows how a program might center a string on a form. |
|
|
|
 |
|
|
|
|
Private Sub Form_Load()
CurrentX = ScaleWidth / 2 - TextWidth("Some Text") / 2
CurrentY = ScaleHeight / 2 - TextHeight("Some Text") / 2
Print "Some Text"
Line (0, 0)-(ScaleWidth, ScaleHeight)
Line (0, ScaleHeight)-(ScaleWidth, 0)
End Sub |
|
|
|
|
|
|
|
|
The situation is much more complicated when the text is rotated. The TextWidth and TextHeight functions return the dimensions of the text as if it were not rotated; they do not return the dimensions of the rotated text. TextHeight can become confused when you use SelectObject to select a customized font, making its value completely useless. |
|
|
|
|
|
|
|
|
Figure 4.10 shows the geometry of a rotated string. This picture seems intimidating, but it is manageable when considered in small pieces. |
|
|
|
|
|